<?php
declare(strict_types=1);

namespace App\Controller\Backend;

use App\Logic\AdminPlayLogic;
use Hyperf\HttpServer\Annotation\AutoController;
use Psr\Http\Message\ResponseInterface;

#[AutoController(prefix: '/play', server: 'backend')]
class PlayController extends AbstractController
{
    /**
     * 比赛列表
     * @return ResponseInterface
     */
    public function lists(): ResponseInterface
    {
        $input = $this->request->all();
        return $this->apiReturn(200, 'succ', AdminPlayLogic::listPlay($input));
    }

    /**
     * 比赛详情
     * @return ResponseInterface
     */
    public function detail(): ResponseInterface
    {
        $matchId = $this->request->input('matchId', '');
        if (empty($matchId)) {
            return $this->apiReturn(400, '参数错误');
        }
        try {
            $detail = AdminPlayLogic::detailPlay($matchId);
            return $this->apiReturn(200, 'succ', $detail);
        } catch (\Exception $e) {
            return $this->apiReturn(400, $e->getMessage());
        }
    }
}

